package com.quick.develop.flowable.service.task.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.quick.develop.flowable.domain.vo.draft.BpmDraftReqVO;
import com.quick.develop.framework.common.page.PageResult;
import com.quick.develop.framework.security.utils.SecurityUtils;
import com.quick.develop.flowable.domain.draft.BpmDraftEx;
import com.quick.develop.flowable.domain.draft.BpmDraftPageReqVO;
import com.quick.develop.flowable.framework.convert.task.BpmDraftConvert;
import com.quick.develop.flowable.mapper.BpmDraftMapper;
import com.quick.develop.flowable.service.task.IBpmDraftService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author junyuan.liu
 * @description: 
 * @date 2022/6/16 10:35
 */
@Service
@Slf4j
public class BpmDraftServiceImpl extends ServiceImpl<BpmDraftMapper, BpmDraftEx> implements IBpmDraftService {
    @Override
    public PageResult<BpmDraftEx> selectPage(BpmDraftPageReqVO reqVO) {
        String userId = SecurityUtils.getUserCode();
        
        return baseMapper.selectPage(userId, reqVO);
    }

    @Override
    public long getDraftCount() {
        String userId = SecurityUtils.getUserCode();
        return baseMapper.getDraftCount(userId);
    }

    @Override
    public void addDraft(BpmDraftReqVO reqVO) {
        BpmDraftEx draftEx = BpmDraftConvert.INSTANCE.convert(reqVO);
        baseMapper.insert(draftEx);
    }

    @Override
    public int updateDraft(BpmDraftReqVO reqVO) {
        BpmDraftEx draftEx = BpmDraftConvert.INSTANCE.convert(reqVO);
        return baseMapper.updateById(draftEx);
    }

    @Override
    public int deleteDraftById(Long id) {
        return baseMapper.delDraftById(id);
    }
}
